package com.kk.base.dao.home;

import com.kk.base.entity.home.BranchApplyFor;
import com.kk.base.entity.home.BranchApplyForStatusEnum;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 网点申请数据库处理层
 */
@Repository
public interface BranchApplyForDao extends JpaRepository<BranchApplyFor,Long>, JpaSpecificationExecutor<BranchApplyFor> {


    /**
     * 通过id查询网点申请
     * @param id
     * @return
     */
    @Query("select baf from BranchApplyFor baf where id = :id")
    BranchApplyFor find(@Param("id")Long id);


    /**
     * 根据申请网点名查询
     * @param branchName
     * @return
     */
    BranchApplyFor findByBranchName(String branchName);

    /**
     * 通过申请人查询
     * @param homeUserId
     * @return
     */
    List<BranchApplyFor> findByHomeUser_Id(Long homeUserId);

    /**
     * 通过状态和前台用户查询
     * @param homeUserId
     * @param branchApplyForStatus
     * @return
     */
    BranchApplyFor findByHomeUser_IdAndBranchApplyForStatus(Long homeUserId, BranchApplyForStatusEnum branchApplyForStatus);


}
